#include <fstream>
#include <sstream>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <vector>
using namespace std;
#define PI (acos(0.0)*2.0)
#define forn(i,n) for(int i=0;i<int(n);++i)
#define forsn(i,s,n) for(int i=s;i<int(n);++i)
#define dforn(i,n) for(int i=int(n)-1;i>=0;--i)
typedef pair<double,double> pdouble;


#define DEB(a) {cout << #a << ":" << a << endl; }

template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >& v) {
    o << "{";
    forn(i,v.size()) o << (i?",":"") << v[i] << endl;
    return o << "}";
}

template<typename T>
ostream& operator<<(ostream& o, const vector<T>& v) {
    o << "{";
    forn(i,v.size()) o << (i?",":"") << v[i];
    return o << "}";
}

class test {
public:
	test(string s) {
		istringstream in(s);
		in >> n >> m >> ti >> to >> h >> k;
		assert(n>1);
		assert(m>1);
		assert(0<to && to<=ti);
		assert(h>0);
		assert(k>0);
		r.resize(n);
		forn(i,n) {
			in >> r[i];
			assert(0<=r[i] && r[i]<=m);
		}
		off.resize(n+1); off[0]=0;
		forn(i,n) off[i+1]=off[i]+m-r[i];
	}
	int cn() const { return off[n]; }
	int id(int i, int j) const {
	    i=((i%n)+n)%n; //wrap around angles
    	if(r[i]<j&&j<=m) return off[i]+j-r[i]-1;
    	else if (0<=j && j<=r[i]) return -1;
    	else return -2;
	}
	friend void solveTest(ostream& o, const test& t);
private:
	int n,m; double ti,to,h,k;
	vector<int> r;
	vector<int> off;
	
};

typedef vector<vector<double> > mat;

vector<int> gaussElim(mat& a) {

	int n=a.size();
	assert(n>0);
	forn(i,n) assert(int(a[i].size())==n+1);
    vector<int> perm(n); forn(i,n) perm[i]=i;
	forn(i,n) {
		int mi,mj; double ma=0.0;
		forsn(ni,i,n)forsn(nj,i,n) if (abs(a[ni][nj])>ma) {
			ma=abs(a[ni][nj]); mi=ni; mj=nj;
		}
		if (ma==0.0) {//a is singular
           cout << "GAUSS PANIC" << endl; break;
        } 
        swap(a[i],a[mi]); //swap rows
	    forn(ni,n) swap(a[ni][i],a[ni][mj]); //swap cols
        swap(perm[i],perm[mj]); //update permutation "matrix"
		forsn(ni,i+1,n) {
			forsn(j,i+1,n+1) a[ni][j]-=a[i][j]*a[ni][i]/a[i][i];
			a[ni][i]=0.0;
		}
	}
    return perm;
}

vector<double> solve(mat& a) {
	vector<int> perm = gaussElim(a);
	int n=a.size(); assert(n>0);
	forn(i,n) assert(int(a[i].size())==n+1);
	vector<double> res(n,0.0);
	dforn(i,n) {
		res[i]=a[i][n];
		forsn(j,i+1,n) res[i]-=a[i][j]*res[j];
		res[i]/=a[i][i];
	}
    vector<double> r(n);
    forn(i,n) r[perm[i]]=res[i];
	return r;
}

struct term {
	int id;	double val;
	term(int i, double v) : id(i),val(v) {}
};
ostream& operator<<(ostream& o, const term& t) {
    return o << "(" << t.id << "," << t.val << ")";
}
typedef vector<term> terms;
void addEq(int& eqn, mat& a, terms ts, double res) {
	assert(0<=eqn && eqn<int(a.size()));
	int n=a[eqn].size()-1;
	assert(n>0);
	forn(i,n) a[eqn][i]=0.0;
	a[eqn][n]=res;
	forn(i,ts.size()) {
		assert(0<=ts[i].id && ts[i].id<n);
		a[eqn][ts[i].id]=ts[i].val;
		
	}
	
	eqn++;
}

void condAdd(int id, double val, double undefVal, double& res, terms& ts) {
	assert(-1<=id);
	if (id==-1) res-=undefVal*val;
	else ts.push_back(term(id,val));
}

void solveTest(ostream& o, const test& t) {
	int cn=t.cn();
	mat ab(cn,vector<double>(cn+1,0.0));

	int eqn=0;
	
	//inside equations (1)
	double dr=1.0/t.m,da=2.0*PI/t.n;
    double da2=da*da,dr2=dr*dr;
	forn(i,t.n)forsn(j,t.r[i]+1,t.m) {
		double res=0.0;
        terms e;
        condAdd(t.id(i,j), -2.0/dr2 + 1.0/(dr2*j) - 2.0/(da2*dr2*j*j), 
        	t.ti, res, e);
     	condAdd(t.id(i,j-1), 1.0/dr2 - 1.0/(dr2*j), t.ti, res, e);
     	condAdd(t.id(i,j+1), 1.0/dr2, t.ti, res, e);
     	condAdd(t.id(i-1,j), 1.0/(da2*dr2*j*j), t.ti, res, e );
     	condAdd(t.id(i+1,j), 1.0/(da2*dr2*j*j), t.ti, res, e );
        addEq(eqn, ab, e, res);
	}
	
	//outter border equations (3)
    forn(i,t.n) {
        terms e;
        double res=t.to;
        condAdd(t.id(i,t.m)  , t.k/(dr*t.h) + 1.0, t.ti, res, e);
        condAdd(t.id(i,t.m-1), -t.k/(dr*t.h), t.ti, res, e);
        addEq(eqn, ab, e, res);
    }
	
	vector<double> res=solve(ab);

	mat sol(t.n, vector<double>(t.m+1, t.ti));
	
	forn(i,t.n)forn(j,t.m+1) {
		int id=t.id(i,j);
		sol[i][j]=(id==-1?t.ti:res[id]);
	}
	
	//forn(i,t.n)forsn(j,t.r[i],t.m+1)  //dummy sol
     //   sol[i][j]=t.ti+(t.to-t.ti)/(double(j+1-t.r[i]));
	
	o << t.n << " " << t.m << endl;
	forn(i,t.n){
		forn(j,t.m+1) {
			if (j) o << " ";
			o.precision(10);
			o << sol[i][j];
		}
		o << endl;
	}
}

string fix(string s) {
	//if (s.size()>10) s=s.substr(0,10);	
	forn(i,s.size()) if (!isalnum(s[i])) s[i]='_';
	return s;
}

void proc(string ln) {
	ostringstream outName;
	outName << "res_" << fix(ln) << ".pm";
	cout << outName.str() << endl;
	ofstream out(outName.str().c_str());
	solveTest(out, test(ln));
}

bool isWhite(char c) { return c==' ' || c=='\n' || c=='\t'; }
int main(int argc, char** argv) {
	if(argc < 2) {
		cerr << "faltan parametros\n";
		return 1;
	}
	ifstream in(argv[1]);
    string ln;
	while(getline(in,ln)) {
		bool com=true;
		forn(i,ln.size()) if (!isWhite(ln[i])) 
			{ com=(ln[i]=='#');  break; }
		if (!com) proc(ln);
	}
	return 0;
}
